package com.qf.controller;

import com.qf.pojo.TUser;
import com.qf.service.TUserService;
import com.qf.utils.Result;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Controller
@RequiredArgsConstructor
public class UserController {
    private final TUserService userService;
    @PostMapping("/login.do")
    public String login(@RequestParam("username") String username,
                        @RequestParam("password") String password) {
       // userService.login(username,password);
        TUser user = userService.login(username);
        //验证密码
        if (user != null && user.getPassword().equals(password)) {
            return "redirect:/pages/main.html";
        }
        return "redirect:/pages/login.html";
    }

}
